#include "readfile.h"

#include <QFile>
#include <QFileInfo>
#include <QThread>

ReadFile::ReadFile(QObject *parent)
    : QObject{parent}
{

}

void ReadFile::readFile(QString path)
{
    qDebug()<<"ReadFile threadId"<<QThread::currentThread();
    QFile file(path);
    QFileInfo info(path);

    file.open(QFile::ReadOnly);
    int fileSize=info.size();
    int num = 0;
    while(!file.atEnd())
    {
        if(num==0)
        {
            num = 4;
        }
        QByteArray line = file.readLine();
        qDebug()<<"line"<<line;
        num += line.size();
        int percent = (num*100/fileSize);
        qDebug()<<percent;
        emit currentValue(percent);
    }
}
